<?php
	include_once ('sgbd.php');
	
	function authenticate($log) {
/*		$login = $_SESSION['login'];
		$passwd = $_SESSION['passwd'];*/
		$login = $_COOKIE['login'];
		$passwd = $_COOKIE['passwd'];
		
		$query = "SELECT * FROM USER WHERE login = '$login' AND passwd = '$passwd'";
		$res = query ($query);
		$lines = mysql_num_rows($res);
		
		close ();
		
		if ($lines == 1) {	// auth OK
			if ($log == true) {
				$query = "INSERT INTO LOG VALUES ('$login', NOW(), '1')";
				query ($query);
			}

			return true;
		} else {
			return false;
		}
	}

?>
